package com.crk.yiyuanguahao.controller;

import com.crk.yiyuanguahao.entity.DoctorFeedback;
import com.crk.yiyuanguahao.service.DoctorFeedbackService;
import com.crk.yiyuanguahao.util.LayUiTableJson;
import com.crk.yiyuanguahao.util.Page;
import com.crk.yiyuanguahao.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author
 * @description:
 * @date 2020/3/26
 */
@RestController
@RequestMapping("doctorFeedback")
public class DoctorFeedbackController {
    @Autowired
    DoctorFeedbackService doctorFeedbackService;

    @RequestMapping("manage")
    public ModelAndView manage(){
        ModelAndView modelAndView = new ModelAndView("/workspace/doctorFeedback/doctorFeedbackList.html");
        return modelAndView;
    }

    @GetMapping("detail")
    public ModelAndView detail(){
        ModelAndView modelAndView = new ModelAndView("/workspace/doctorFeedback/doctorFeedbackAdd.html");
        return modelAndView;
    }
    @RequestMapping("saveDoctorFeedback")
    public ResponseResult saveDoctorFeedback(DoctorFeedback doctorComment){
        return doctorFeedbackService.saveDoctorFeedback(doctorComment);
    }

    @RequestMapping("deleteDoctorFeedback")
    public ResponseResult deleteDoctorFeedback(@RequestParam("id") Integer id){
        return doctorFeedbackService.deleteDoctorFeedback(id);
    }

    @RequestMapping("getDoctorFeedback")
    public ResponseResult getDoctorFeedback(@RequestParam("id") Integer id){
        return doctorFeedbackService.getDoctorFeedback(id);
    }

    @RequestMapping("queryDoctorFeedbackPage")
    public LayUiTableJson queryDoctorFeedbackPage(int status
            , @RequestParam(defaultValue = "1") int page
            , @RequestParam(defaultValue = "10") int limit){
        Page pageInfo = new Page();
        pageInfo.setCurrentPage(page);
        pageInfo.setSize(limit);
        ResponseResult ResponseResult = doctorFeedbackService.queryDoctorFeedbackPage(status,pageInfo);
        LayUiTableJson layUiTableJson = new LayUiTableJson(0,null,pageInfo.getAllRow(),(List)ResponseResult.getData());
        return layUiTableJson;
    }

    @RequestMapping("approval")
    public ResponseResult approval(@RequestParam("id") int id,@RequestParam("status") int status){
        return doctorFeedbackService.approval(id,status);
    }
}
